package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entity.CommonResult;
import com.atguigu.springcloud.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @USER: dayu
 * @DATE: 2020/4/16
 * @DESCRIPTION:
 */
@RestController
public class PaymentController {
    @Value("${server.port}")
    String port;
    public static HashMap<Long, Payment> hashMap=new HashMap<>();
    static {
        hashMap.put(1L,new Payment(1L,"b17f24ff026d40949c85a24f4f375d42"));
        hashMap.put(2L,new Payment(2L,"b17f24ff026d40949c85a24f4f375d43"));
        hashMap.put(3L,new Payment(3L,"b17f24ff026d40949c85a24f4f375d44"));
    }


    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id")Long id){
        Payment payment= hashMap.get(id);
        return new CommonResult<>(200,"from sql :server.port="+port,payment);
    }
}
